package com.lagou.mr.task1;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;


public class NumSortMapper extends Mapper<LongWritable, Text, IntWritable, NullWritable> {

    IntWritable n = new IntWritable();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        //读取一行文本数据转为IntWritable,IntWritable默认升序排序，不要再进行排序
        String line = value.toString();
        Integer num = Integer.parseInt(line);
        n.set(num);
        //数据写出
        context.write(n,NullWritable.get());
    }
}
